<template>
	<view class="index">
		<view class="banner">
			<u-swiper bg-color="transparent" name="showurl" :list="banner"></u-swiper>
		</view>
		<view class="tag">
			<u-tabs 
			height="60"
			:active-item-style='active' 
			bg-color="transparent" 
			:list="list" 
			bar-width="50%" 
			inactive-color="rgba(94, 106, 252,0.8)"
			active-color="#ffffff" 
			:is-scroll="false" 
			:current="current" 
			@change="change"></u-tabs>
		</view>
		<view class="content">
			<rich-text :nodes="content"></rich-text>
			<view class="message">
				<u-empty v-if="!content" text="暂无合约内容" mode="message"></u-empty>
			</view>
			
		</view>
		<Nav :current='navActive'></Nav>
	</view>
</template>
<script>
	import Nav from '../../component/Nav.vue'
	export default {
		components:{
			Nav
		},
		data() {
			return {
				banner:[],
				active: {
					border: '1px solid #5e6afc',
					backgroundColor:'#5e6afc',
					borderRadius: '12rpx',
				},
				list: [
					{name: '正向合约'}, 
					{name: '反向合约'},
				],
				current: 0,
				navActive:0,
				page:1,
				list_rows:10,
				dataContent:{},
				content:''
			}
		},
		onReady() {
			
		},
		onLoad() {
			this.getBanner()
			this.getData()
		},
		onPullDownRefresh(){
			this.current = 0
			this.getData()
			this.getBanner()
		},
		methods: {
			//获取banner
			getBanner(){
				this.$http({
					url:this.$api.banner_getAll,
					method:'POST',
					hideLoading:false,
					data:{
						page:1,
						list_rows:6,
					},
					success:res=>{
						uni.stopPullDownRefresh();
						//console.log('res----data',res.data)
						this.banner = res.data.data
						
					},
					fail:err=>{
						uni.stopPullDownRefresh();
						//console.log('失败返回------',err)
					}
				})
				//console.log('banner',this.banner)
			},
			getData(){
				this.$http({
					url:this.$api.index_getAll,
					method:'POST',
					hideLoading:false,
					success:res=>{
						this.dataContent = res.data
						//console.log('content------------',this.dataContent)
						this.content = this.dataContent.zhenghx || ''
					},
					complete:e=>{
						uni.stopPullDownRefresh();
					}
				})
			},
			//切换
			change(index) {
				this.current = index;
				if(index == 0){
					this.content = this.dataContent.zhenghx || ''
				}else{
					this.content = this.dataContent.fanhx || ''
				}
			}
		}
	}
</script>
<style lang="scss" scoped>
	.index {
		.banner {
			margin: 80rpx 0 40rpx 0;
		}
		::v-deep .u-swiper-indicator{
			bottom: 14px!important;
		}
		.tag {
			margin: 0 24rpx;
			border: 1px solid rgba(94, 106, 252,0.5);
			border-radius: 15rpx;
		}
		.content{
			padding: 30rpx;
			margin: 30rpx;
			border: 1rpx solid $border-bottom-color;
			border-radius: 10rpx;
			background-color: $border-bottom-color;
			color: #F8F8F8;
			::v-deep img{
				max-width: 100%;
			}
			.message{
				position: absolute;
				top:50%;
				left: 0;
				width: 100%;
			}
		}
	}
</style>
